package com.t235.gc.operations.controller;

import com.t235.gc.AjaxResult;
import com.t235.gc.entity.DeviceCabinet;
import com.t235.gc.operations.service.DeviceCabinetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/cabinet")
public class DeviceCabinetController {
    @Autowired
    private DeviceCabinetService deviceCabinetService;

    @PostMapping("/admin/updateGoodsPosition")
    public AjaxResult updateGoodsPosition(Integer goodsid,Integer rownumber,Integer columnnumber){
        return AjaxResult.success(deviceCabinetService.updateGoodsPosition(goodsid,rownumber,columnnumber));
    }

    @PostMapping("/admin/updateGoodsStockQty")
    public AjaxResult updateGoodsStockQty(Integer goodsid,Integer stockqty){
        return AjaxResult.success(deviceCabinetService.updateGoodsStockQty(goodsid,stockqty));
    }

    @GetMapping("/admin/selectLessStockGoods")
    public AjaxResult selectLessStockGoods(){
        List<DeviceCabinet> deviceCabinets =deviceCabinetService.selectLessStockGoods();
        return AjaxResult.success(deviceCabinets);
    }

    @GetMapping("/admin/selectGoods")
    public AjaxResult selectGoods(){
        List<DeviceCabinet> deviceCabinets = deviceCabinetService.selectGoods();
        return AjaxResult.success(deviceCabinets);
    }
}
